package com.eshipenet.shipnet.commplanrpc.util;

import com.eshipenet.shipnet.CommCard.grpc.CommCard;
import com.eshipenet.shipnet.CommCard.grpc.CommCardEdge;
import com.eshipenet.shipnet.commplan.CommPlan;
import com.eshipenet.shipnet.commplan.grpc.CommPlanEdge;

import javax.cache.Cache;

public class BuilderUtil {


    public static CommPlanEdge commPlanEdgeBuilder(Cache.Entry<String, CommPlan> p){

        return CommPlanEdge.newBuilder().setNode(com.eshipenet.shipnet.commplan.grpc.CommPlan
                .newBuilder()
                .setId(p.getKey())
                .setName(p.getValue().getName())
                .setDescription(p.getValue().getDescription())
                .setKind(p.getValue().getKind())
                .setAvatar(p.getValue().getAvatar())
                .setQuotaData(p.getValue().getQuotaData())
                .setQuotaFreq(p.getValue().getQuotaFreq())
                .setStatus(p.getValue().getStatus())
                .setCreatedAt(TimestampToDate.dateTotimestamp(p.getValue().getCreatedAt()))
                .setUpdatedAt(TimestampToDate.dateTotimestamp(p.getValue().getCreatedAt()))
                .setInfo(GetJObjectUtil.getData(p.getValue().getInfo())))
                .setCursor(p.getKey())
                .build();
    }


    public static CommCardEdge commCardEdgeBuilder(Cache.Entry<String, com.eshipenet.shipnet.commplan.CommCard> p){

        return CommCardEdge.newBuilder().setNode(CommCard.newBuilder()
                                                         .setId(p.getKey())
                                                         .setCardId(p.getValue().getCardId())
                                                         .setPlanId(p.getValue().getPlanId())
                                                         .setName(p.getValue().getName())
                                                         .setDescription(p.getValue().getDescription())
                                                         .setKind(p.getValue().getKind())
                                                         .setAvatar(p.getValue().getAvatar())
                                                         .setStatus(p.getValue().getStatus())
                                                         .setCreatedAt(TimestampToDate.dateTotimestamp(p.getValue().getCreatedAt()))
                                                         .setUpdatedAt(TimestampToDate.dateTotimestamp(p.getValue().getCreatedAt()))
                                                         .setInfo(GetJObjectUtil.getData(p.getValue().getInfo())))
                           .setCursor(p.getKey())
                           .build();
    }



}
